package isi_ib;

import java.util.Date;

import utiles_isi.dateutil;

public class barra_trade {
	private int reqId;
	private String date;
	private double open;
	private double high;
	private double low;
	private double close;
	private long volume;
	private int count;
	private double WAP;
	private boolean hasGaps;
	//private int periodo;
		
	
	public int getReqId() {
		return reqId;
	}
	public void setReqId(int reqId) {
		this.reqId = reqId;
	}
/*	public String getDate() {
		return date;
	}*/
	
	public Date getDate() {
		return dateutil.dateFromEpochString(date);
		
	}
	public String getDateString(){
		return dateutil.fechahorastring("", getDate());
	}
	public long getDatelong() {
		
		return Long.parseLong(date);
		
	}
	public void setDate(String date) {
		this.date = date;
	}
	public double getOpen() {
		return open;
	}
	public void setOpen(double open) {
		this.open = open;
	}
	public double getHigh() {
		return high;
	}
	public void setHigh(double high) {
		this.high = high;
	}
	public double getLow() {
		return low;
	}
	public void setLow(double low) {
		this.low = low;
	}
	public double getClose() {
		return close;
	}
	public void setClose(double close) {
		this.close = close;
	}
	public long getVolume() {
		return volume;
	}
	public void setVolume(int volume) {
		this.volume = (long)volume;
	}
	public void setVolume(long volume) {
		this.volume = volume;
	}
	public int getPeriodo() {
		return 0;
	}
	
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	
	public double getWAP() {
		return WAP;
	}
	public void setWAP(double wAP) {
		WAP = wAP;
	}
	public boolean isHasGaps() {
		return hasGaps;
	}
	public void setHasGaps(boolean hasGaps) {
		this.hasGaps = hasGaps;
	}
	public String getFromName(String name_) {
		
		name_=name_.toLowerCase();
		if (name_.contentEquals("reqid")) return String.valueOf(reqId);else
			if (name_.contentEquals("count")) return String.valueOf(count);else
				if (name_.contentEquals("date")) return date;else
					if (name_.contentEquals("open")) return String.valueOf(open);else
						if (name_.contentEquals("high")) return String.valueOf(high);else
							if (name_.contentEquals("low"))return String.valueOf(low);else
								if (name_.contentEquals("close"))return String.valueOf(close);else
									if (name_.contentEquals("volume"))return String.valueOf(volume);else
										if (name_.contentEquals("wap"))return String.valueOf(WAP);else
											if (name_.contentEquals("periodo"))return String.valueOf(getPeriodo());else
												if (name_.contentEquals("hasGaps"))return String.valueOf(hasGaps);else return "";
		
		
	}
	public double getvalueFromName(String name_) {
		name_=name_.toLowerCase();
		if (name_.contentEquals("reqid")) return reqId;else
		if (name_.contentEquals("count")) return count;else
		if (name_.contentEquals("open")) return open;else
		if (name_.contentEquals("high")) return high;else
		if (name_.contentEquals("low")) return low;else
		if (name_.contentEquals("close")) return close;else
		if (name_.contentEquals("volume")) return volume;else
		if (name_.contentEquals("periodo")) return getPeriodo();else
		return -1;
	}
	

	public void Barra(int reqId, String date, double open,
			double high, double low, double close, long volume, int count,
			double wAP, boolean hasGaps) {
		setReqId(reqId);
		setDate(date);
		setOpen(open);
		setHigh(high);
		setLow(low);
		setClose(close);
		setVolume(volume);
		setCount(count);
		setWAP(wAP);
		setHasGaps(hasGaps);
				//
	}
	

	
	public void copy(barra_trade barr_)
	{
		
		reqId=barr_.reqId;
		date=barr_.date;
		open=barr_.open;
		high=barr_.high;
		low=barr_.low;
		close=barr_.close;
		volume=barr_.volume;
		count=barr_.count;
		WAP=barr_.WAP;
		hasGaps=barr_.hasGaps;
		
			
	}
	public barra_trade(int reqId, String date, double open, double high,
			double low, double close, long volume, int count, double wAP,
			boolean hasGaps) {
		super();
		Barra( reqId,date,open,high,low,close,volume,count,wAP,hasGaps);
	}
	public barra_trade() {
		super();
		Barra( -1,"",-1,-1,-1,-1,-1,-1,-1,false);
	}
	public String toString() {
		return (String.valueOf(reqId)+","+
				String.valueOf(count)+","+
				String.valueOf(date)+","+
				String.valueOf(open)+","+
				String.valueOf(high)+","+
		        String.valueOf(low)+","+
		        String.valueOf(close)+","+
		        String.valueOf(volume)+","+
		        String.valueOf(WAP)+","+
		        String.valueOf(hasGaps)
		        );
		}

}
